
export const EVT_WIDGET_SELECTOR_ITEM_CLICKED = Symbol();
export const EVT_WIDGET_CREATE_BTN_CLICKED = Symbol();
export const EVT_WIDGET_ALL_CREATED = Symbol();
export const EVT_WIDGET_CONTENT_CHANGED = Symbol();
export const EVT_WIDGET_DIRTY_CONTENT_CHANGED_TO_VIEW = Symbol();
export const EVT_WIDGET_CHANGED_TO_VIEW = Symbol();
export const EVT_WIDGET_CHANGED_TO_EDIT = Symbol();
export const EVT_WIDGET_CHANGED_TO_EDIT_FOCUS = Symbol();
export const EVT_WIDGET_CHANGED_TO_EDIT_BLUR = Symbol();
export const EVT_WIDGET_TOOL_DELETE = Symbol();
export const EVT_WIDGET_TOOL_FOCUS = Symbol();
export const EVT_WIDGET_TOOL_CLOSE = Symbol();
export const EVT_WIDGET_TOOL_MOVE_UP = Symbol();
export const EVT_WIDGET_TOOL_MOVE_DOWN = Symbol();

export function WidgetSelectorItemClickedEvent(widgetType, offset) {
    return Object.freeze({
        type: EVT_WIDGET_SELECTOR_ITEM_CLICKED,
        get widgetType() {return widgetType;},
        get offset() {return offset;},
    });
}

export function WidgetAllCreated(collection) {
    return Object.freeze({
        type: EVT_WIDGET_ALL_CREATED,
        get collection() {return collection;},
    });
}

export function CreateBtnClickedEvent(widget, offset) {
    return Object.freeze({
        type: EVT_WIDGET_CREATE_BTN_CLICKED,
        get widget() {return widget;},
        get offset() {return offset;},
    });
}

export function DirtyContentChangedToViewEvent(widget) {
    return Object.freeze({
        type: EVT_WIDGET_DIRTY_CONTENT_CHANGED_TO_VIEW,
        get WID() {return widget.WID;},
    });
}

export function ContentChangedEvent(widget) {
    return Object.freeze({
        type: EVT_WIDGET_CONTENT_CHANGED,
        get WID() {return widget.WID;},
    });
}

export function ChangedToViewEvent(widget, dirty) {
    return Object.freeze({
        type: EVT_WIDGET_CHANGED_TO_VIEW,
        get WID() {return widget.WID;},
        get element() {return widget.element;},
        get changed() {return dirty;},
    });
}

export function ChangedToEditEvent(widget) {
    return Object.freeze({
        type: EVT_WIDGET_CHANGED_TO_EDIT,
        get WID() {return widget.WID;},
        get element() {return widget.element;},
    });
}

export function ChangedToEditBlurEvent(widget) {
    return Object.freeze({
        type: EVT_WIDGET_CHANGED_TO_EDIT_BLUR,
        get WID() {return widget.WID;},
    });
}

const _EMPTY_ARRAY = Object.freeze([]);
export function ChangedToEditFocusEvent(widget) {
    return Object.freeze({
        type: EVT_WIDGET_CHANGED_TO_EDIT_FOCUS,
        get WID() {return widget.WID;},
        get menuElements() {return widget._editPane ? widget._editPane.GetMenuElements() : _EMPTY_ARRAY;},
    });
}





export function MoveUpEvent(WID) {
    return Object.freeze({
        type: EVT_WIDGET_TOOL_MOVE_UP,
        get WID() {return WID;},
    });
}
export function MoveDownEvent(WID) {
    return Object.freeze({
        type: EVT_WIDGET_TOOL_MOVE_DOWN,
        get WID() {return WID;},
    });
}

export function ToolDeleteEvent(WID) {
    return Object.freeze({
        type: EVT_WIDGET_TOOL_DELETE,
        get WID() {return WID;},
    });
}
export function ToolCloseEvent(WID) {
    return Object.freeze({
        type: EVT_WIDGET_TOOL_CLOSE,
        get WID() {return WID;},
    });
}
export function ToolFocusEvent(WID) {
    return Object.freeze({
        type: EVT_WIDGET_TOOL_FOCUS,
        get WID() {return WID;},
    });
}
